<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/app.css">
    <link rel="stylesheet" type="text/css" href="../../css/my.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="/pc/js/all.js"></script>
    <style>
        table {
            padding:5px 5%;
            width:100%;
            background:#fefefe;
            border-bottom:1px solid #f0f0f0;
        }
        td {
            padding:5px;
        }
        .payTime {
            font-size:12px;
        }
        .payName {
            color:#888888;
            font-size:14px;
        }
        .payMoney {
            font-weight:bolder;
            font-size:16px;
            text-align:right;
        }
    </style>
</head>
<body>
<!--
    制作者：九哥
    页面：我的账户-平台收益
    时间：2019-07-30
-->





<!----------我的账户账单---------->
<div id="accountPage">
    <div id="accountTitle">
        <b>我的账户-收益</b>
        <img src="../../images/return.png" id="accountRtn">
    </div>
    <div id="payList">
        <table>
            <tr>
                <td colspan="2">
                    <b>收入类型</b>
                    <span class="payTime">【支付时间】</span>
                </td>
            </tr>
            <tr>
                <td class="payName">支付方名称</td>
                <td class="payMoney">支付金额</td>
            </tr>
        </table>
    </div>
</div>
<div  id="zfb"></div>
<!----------我的账户账单---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../../js/app.js"></script>
<script type="text/javascript" src="../../js/cache.js"></script>
<script type="text/javascript" src="../../js/mysetPageChange.js"></script>
<script type="text/javascript" src="../../js/myset2.js"></script>
</html>

<script>
    (function(){
        getIndex();
    })();
    function getIndex(){
        var cacheKey = 'platTradeList';
        //获取缓存
        var cacheTradeList = cacheGet(cacheKey);
        if (cacheTradeList) {
            $('#payList').html(getTradeList(cacheTradeList));
        } else {
            $('#payList').html("<table><tr><td style='text-align:center;'>加载中...<td></tr></table>");
        }
        //更新数据
        var userInfo = cacheGet('userInfo'); //获取用户信息
        if (userInfo==null || userInfo.token=='undefined') {
            window.location.href = '/h5/login/login.html';
        }
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            type:userInfo.type,
            cate:userInfo.cate
        };
        $.ajax({
            type: 'post',
            url: getDomain() + 'trade',
            data: formData,
            success: function(res){
                //console.log(res); return;
                if (res.code!=0) {
                    $('#payList').html("<table><tr><td style='text-align:center;'>没有记录<td></tr></table>");
                    console.log(res.msg);
                    return
                }
                var resData = res.data;
                console.log(resData);
                $('#payList').html(getTradeList(resData));
                cacheSet(cacheKey,resData); //更新缓存
            },
            error: function(){
                console.log('操作失败！'); return;
            }
        });
    }
    /**
     * 拼接列表
     * */
    function getTradeList(resData){
        var i, h = '';
        for (i=0;i<resData.length;i++) {
            h += '<table>';
            h += '<tr>';
            h += '<td colspan="2">';
            h += '<b>';
            h += resData[i].genreName+'：';
            h += '</b>';
            h += '<span class="payTime">【';
            h += resData[i].createTime;
            h += '】</span>';
            h += '</td>';
            h += '</tr>';
            h += '<tr>';
            h += '<td class="payName">';
            h += resData[i].payName.substring(0,5)+'...';
            h += '</td> ';
            h += '<td class="payMoney"> ';
            h += resData[i].money+'元';
            h += '</td>';
            h += '</tr>';
            h += '</table>';
        }
        return h;
    }
    /**
     * 地址前缀
     * */
    function getDomain(){
        return '/api/my/account/';
    }
</script>